home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Precision Software Appli…tions Silver Collection 4
/
Precision Software Applications Silver Collection Volume 4 (1993).iso
/
stats
/
chadyn.exe
/
YINTRPT.C
< prev
next >
Wrap
Text File
|
1988-12-11
|
35KB
|
1,356 lines
/********************************* YINTRPT.C *********************************/
/***********************(C) 1986,7,8 by JAMES A. YORKE **********************/
/********************* Routines in YINTRPT.C ***********************
Interrupt() Hitting a key while the map is being iterated will summon
intervention
PrintJumpSign()
SetAndSave(new,current,old) saves *current in *old and if new is set, it
sets *current = *new; it then sets *new = *current /
SwitchD(A,B)
SetCross(crossnumber) in YCROSS.C
CrossPosition() in YCROSS.C
turnoff() in YCROSS.C
SwitchI(A,B)
start() used in printing the vector lyapsum /
ResetScrnLineAtTop()
plotImages() This routine initializes y = y1 and plots the several images
of that point; but we don't plot the images each time an
arrow key is hit if we are supposed to be plotting circles and
their images; in other words, wait until the cursor stops
moving; /
***********************************************************************/
#include "yinclud.h"
#ifndef MAINFRAME /* wipes out whole file */
#ifdef MS
#include <bios.h> /* for _bios_keybrd for checking NUM LOCK */
static int palette = 0;
#endif /* MS */
#ifndef X11
static long count;
#endif
/* The values of the following 2 are largely irrelevant */
#define RET 454
#define CONT 2639
static int arrowCounts;
static unsigned shift;
static UvsSflag = 0; /* if 'u' was called more recently than
's',this is 1 */
static int overflow; /* for 'O' circle warning that we have left box
*/
static int kk = 0; /* this is static for purposes of using ALT_O
for drawing a cross only ALT_O is not in use
*/
/* Hitting a key while the map is being iterated will summon
* intervention. Cross 0 is at position of y[] when cycle = 1 or 2 and is
* turned off if cycle = 0; Cross 1 is initially off but is at position
* y1[] if y1 has been reset; if both are set and overlap, they annihilate
* each other where they overlap.
*/
#ifdef X11
/* INTERRUPT - X11 version to avoid infinite loops when single stepping
* and plotting one iterate as the 'p' key is pressed.
*/
Interrupt()
{
int key;
int retval;
static char *pausemsg = "PAUSE at dot #%ld; \
'Esc' terminates pause mode; hit 'p' again for one dot\n";
static char *complaint = "NOT AN ALLOWABLE INTERRUPT\n";
if(cycle == 0) { / usual state unless single stepping */
while((key = awaitkey(1)) != 0
&& (retval = carryOutInt(key)) != RET)
if(retval == NO)
PRINT complaint);
arrowCounts = 0;
return;
} else if(cycle == 1) {
if(level < PROCESS)
PRINT "INTERRUPT MODE: hit any interrupt key; hit 'p' to exit mode \n");
else {
plotSomething(0);
if(IsCross0Set)
SetCross(BIGCROSS);
scr_rowcol(0, 0);
erase_line();
PRINT pausemsg, dot);
}
}
else if(cycle == 2)
overflow = YES;
/* Here we are in single step mode. Wait for a key to be pressed
* and process the interrupt. The external variable CYCLE can be
* altered in carryOutInt.
*/
key = awaitkey(0);
while(key != 0 && cycle > 0) {
retval = carryOutInt(key);
if(retval == NO)
PRINT "NOT AN ALLOWABLE INTERRUPT\n");
else if(retval == RET)
break;
if(printer > 0 && prnFlag == OFF)
PRINT pausemsg, dot);
key = awaitkey(0);
}
arrowCounts = 0;
return;
}
#else
Interrupt()
{
double startTime;
int ret = YES,
carryOutInt();
int keycheck(); /* now local */
/* notice cycle may still be 1 from a previous pass thru Interrupt. That
occurs only when the keycheck() below yields 'o' or 'p'. The only way to
leave this loop is via a return */
/* cycle is either 0 or 1 or 2, and >= 1 if the program is single stepping and
= 2 if this routine was called by plot */
arrowCounts = count = 0;/* certain printing is only done AFTER the
first pass through the loop if cycle > 0;
i.e., if count > 0 */
if(cycle > 0) {
if(cycle == 1 && level >= PROCESS) {
plotSomething(0);
/* 0 means plot but do not iterate map */
if(IsCross0Set == NO)
SetCross(BIGCROSS);
scr_rowcol(0, 0);
erase_line();
if(printer > 0)
PRINT
"PAUSE at dot #%ld; 'Esc' terminates pause mode; hit 'p' again for one dot\n"
,dot);
}
else
if(cycle == 1 && level < PROCESS) {
PRINT
"INTERRUPT MODE: hit any interrupt key; hit 'p' to exit mode \n");
}
else
overflow = YES;/* cycle = 2 warning for 'O' */
}
for(;;) {
if((kk = keycheck()) == 0) {
if(count == 0 && cycle == 0) {
return;
/* this statement assures as little time as
possible will be spent in this routine in
this default case */
}
if(count > 0) {
startTime = timeofday();
#define SEC 0.55
/* SEC is how long(in seconds) my keyboard waits, when
you hold a key down, before telling the computor
that it has been held down and has not been released
*/
while((kk = keycheck()) == 0
&& timeofday() - startTime < SEC);
/* only look for a non-zero kk and keep looking
for SEC seconds */
}
if(kk == 0 && cycle == 0) {
/* reach here if count > 0 */
arrowCounts = 0;
/* reach here if in pause mode and no key has
been hit recently */
return;
}
if(kk == 0 && cycle > 0) {
scr_rowcol(0, 0);
if(printer > 0 && prnFlag == OFF)
PRINT
"PAUSE at dot #%ld; 'Esc' terminates pause mode; hit 'p' again for one dot\n"
,dot);
}
}
count++; /* certain printing is only done AFTER the
first pass through the loop if cycle > 0;
i.e., if count > 0 */
if(kk != 0) {
ret = carryOutInt(kk);
if(ret == RET)
return;
if(ret == NO)
PRINT "NOT AN ALLOWABLE INTERRUPT \n");
}
else
arrowCounts = 0;
/* reach here if in pause mode and no key has
been hit recently */
/* if cycle is 1 or 2 the cross0 should be set and will be set unless
it was turned off because of F1 ...F4 of F10 */
} /* end of for(;;) loop */
}
#endif /*ifdef X11 else */
PrintJumpSign() {
if(SignIsOn == 1)
return;
SignIsOn = 1;
if(printer > 0) {
scr_rowcol(21, 0);
erase_line();
PRINT
"ON NUMERIC KEYPAD: 1 halves jump size for small cross position, 3 doubles it"
);
}
scr_rowcol(0, 0);
}
SetAndSave(new, current, old) /* saves *current in *old and if new is set,
it sets *current = *new; it then sets *new =
*current */
double *new,
*current,
*old;
{
*old = *current;
if(*new != -9999.)
*current = *new;
*new = *current;
}
SwitchD(A, B)
double *A,
*B;
{
double temp;
temp = *A;
*A = *B;
*B = temp;
}
SwitchI(A, B)
int *A,
*B;
{
int temp;
temp = *A;
*A = *B;
*B = temp;
}
ResetScrnLineAtTop() {
scr_rowcol(0, 0); /* move cursor to upper left, a routine in
desmet's pcio.a */
erase_line();
if(cycle == 1) {
PRINT "\n"); /* skip line */
erase_line();
}
}
plotImages() { /* This routine initializes y = y1 and plots
the several images of that point; but we
don't plot the images each time an arrow key
is hit if we are supposed to be plotting
circles and their images; in other words,
wait until the cursor stops moving; */
int i;
if(images == 0)
return;
stoplines(); /* for stopping drawing connected lines */
start(); /* sets dot = 0 and lyap exponents are
restarted */
setequal(0, 1, eqn1);
if(taskFlag != PLOTCIRC) {
turnoff(BIGCROSS);
for(i = 0; i < images; i++)
plotSomething(1);/* plots a point and iterates */
plotSomething(0);/* plots a point and does not iterate */
plotSomething(0);
/* otherwise the last point doesnt get plotted
on CRT when images > 0 */
SetCross(SMALLCROSS);
if(cycle > 0) {
SetCross(BIGCROSS);
/* SetCross(BIGCROSS); */
}
}
}
int isNumLockOn() {
#ifdef MS
shift = _bios_keybrd(_KEYBRD_SHIFTSTATUS);
/* for checking NUM LOCK */
if((shift & mask[7 - 5]) != 0)
return(YES);
#endif /* MS */
return(NO);
}
int carryOutInt(kk)
int(kk);
{
char CodeName[MAXCHAR+1];
FILE * saveptr;
int checkPrinter();/* make sure printer is on line */
int strcmp(); /* to see if we have the henon map */
int keycheck(); /* now local */
int printerStatus();
int random(), set_box();
int digit,
i,
coord,
oldTaskFlag,
isNumLockOn();
int ss; /* temporary ScrnSec */
int temp,
temp1,
saveTaskFlag;
int oldTicFlag;
double doubleDot;
double old_rho;
int saveIter = iter,
saveGoodIterate = goodIterate,
saveOldGoodIt = oldGoodIt;
double saveFrac = frac,
saveAdd = add,
saveLength = length;
if(isNumLockOn() == YES) {
scr_rowcol(3, 0);
erase_line();
scr_rowcol(3, 0);
PRINT
"NumLock is on; hit NumLock key and thereby turn it off;\n");
return(RET);
}
if(kk == LEFT) { /* 75 is code for "left" key */
coord = eqn0 + ssX_coord[ScrnSec];
y[coord] -= ((arrowCounts + 3) / 3) *
screen_fraction *(X_upper - X_lower);
SetCross(SMALLCROSS);
PrintJumpSign();
plotImages();
arrowCounts++;
return(CONT); /* this allows the program to check for another
arrow command even though we are not in
single stepping mode */
}
if(kk == RIGHT) { /* code for right key */
coord = eqn0 + ssX_coord[ScrnSec];
y[coord] += ((arrowCounts + 3) / 3) *
screen_fraction *(X_upper - X_lower);
SetCross(SMALLCROSS);
PrintJumpSign();
plotImages();
arrowCounts++;
return(CONT); /* this allows the program to check for another
arrow command even though we are not in
single stepping mode */
}
if(kk == DOWN) { /* 80 is code for down key */
coord = eqn0 + ssY_coord[ScrnSec];
y[coord] -= ((arrowCounts + 3) / 3) *
screen_fraction *(Y_upper - Y_lower);
SetCross(SMALLCROSS);
PrintJumpSign();
plotImages();
arrowCounts++;
return(YES); /* this allows the program to check for another
arrow command even though we are not in
single stepping mode */
}
if(kk == UP) { /* 72 is IBM code for up key */
coord = eqn0 + ssY_coord[ScrnSec];
y[coord] += ((arrowCounts + 3) / 3) *
screen_fraction *(Y_upper - Y_lower);
SetCross(SMALLCROSS);
PrintJumpSign();
plotImages();
arrowCounts++;
return(CONT); /* this allows the program to check for another
arrow command even though we are not in
single stepping mode */
}
scr_rowcol(0, 0); /* move cursor to upper left, a routine in
desmet's pcio.a */
if(cycle == 1) { /* do not plot if cycle == 2 */
plotSomething(0);/* 0 means plot but do not iterate map */
if(IsCross0Set == NO)
SetCross(BIGCROSS);
}
if(kk == 'o' || kk == 'p') {/* 'o' is archaic usage */
if(cycle == 0) {
SetCross(SMALLCROSS);
SetCross(BIGCROSS);
}
cycle = 1;
return(RET);
}
SetCross(SMALLCROSS);
/* this is after kk == 'p'; if trying to iterate quickly, there is no need to
set cross 1; if we do it slowly, there will be interspersed lots of cases
of kk = 0 and then it will get set */
if(num_lyap > 0 && printer > 0)
PRINT "\n");
if(ODEcheck > 0 && printer > 0)
PRINT "\n");
if(kk == ESC) {
turnoff(BIGCROSS);
ResetScrnLineAtTop();
cycle = 0;
return(RET);
}
if(kk == '#' || kk == ':') {
saveTaskFlag = taskFlag;
saveptr = input;/* in case input is from a file */
input = StInput;
scr_rowcol(0, 0);
definitely_erase_line();
if(printer > 0) {
ret_erase_line(4);
PRINT
"#############################################################################"
);
scr_rowcol(0, 0);/* leave line 0 blank now */
PRINT
"\nEach Interrupt ':' permits you only ONE command(= one menu item). \n");
PRINT
"Hit Return key now if you now want to return to plotting. \n");
PRINT
"Enter Menu item(MM = MainMenu; * plus code gives help):\n");
}
else {
PRINT "\n");
definitely_erase_line();
}
scr_rowcol(0, 0);
definitely_erase_line();
PRINT "ENTER COMMAND: ");
GetCommandAndImplement(CodeName);
if(printer > 0) {
scr_rowcol(0, 0);
erase_line();
ret_erase_line(1);
scr_rowcol(0, 0);
PRINT
"####################### Hit r to refresh the screen. ########################"
);
}
else {
scr_rowcol(0, 0);
definitely_erase_line();
PRINT "\n");
definitely_erase_line();
scr_rowcol(0, 0);
}
input = saveptr;/* return input to previous setting */
taskFlag = saveTaskFlag;
/* the following are for YU.C */
frac = saveFrac;
add = saveAdd;
length = saveLength;
iter = saveIter;
goodIterate = saveGoodIterate;
oldGoodIt = saveOldGoodIt;
SetCross(SMALLCROSS);
/* this is needed if color has been changed */
return(YES);
}
if(kk == ' ') { /* routine should end & go to menu */
taskFlag = -1; /* this means that when plotsomething() is
called, we do not plot a dot */
SignIsOn = NO; /* sign about jump size */
if(level >= PROCESS)
level--;
if(level < PROCESS)
cycle = NO;
else
if(printer > 0) {
scr_rowcol(5, 0);
erase_line();
if(cycle > 0)
PRINT "paused. ");
PRINT "level = menu+%d \n", level - 2);
}
scr_rowcol(0, 0);
return(RET);
}
if(kk == End) { /* 79 is code for end key */
screen_fraction = screen_fraction / 2.;
if(printer > 0) {
scr_rowcol(23, 0);
erase_line();
PRINT
"arrow keys shift and reinitialize y1 by this fraction of the screen:%3.3le \r"
,screen_fraction);
}
ResetScrnLineAtTop();
return(YES);
}
if(kk == PgDn) { /* 81 is code for Pg Dn key */
screen_fraction = screen_fraction * 2.;
if(printer > 0) {
scr_rowcol(23, 0);
erase_line();
PRINT
"arrow keys shift and reinitialize y1 by this fraction of the screen:%3.3le \r"
,screen_fraction);
}
ResetScrnLineAtTop();
return(YES);
}
if(kk == Home) { /* 71 is code for home key */
rho_step = rho_step / 2.;
if(printer > 0) {
erase_line();
PRINT "rho increment = %lf, rho=%lf \r",
rho_step, rho);
}
return(YES);
}
if(kk == PgUp) { /* 73 is code for Pg Up key */
rho_step = rho_step * 2.;
if(printer > 0) {
erase_line();
PRINT "change in rho = %lf, rho=%lf \r",
rho_step, rho);
}
return(YES);
}
if(kk == '+') { /* to declare picture finished */
start(); /* sets dot = 0 and lyap exponents are
restarted */
old_rho = rho;
*pIncrement += rho_step;
if(pIncrement == &rho && rho_final == old_rho)
rho_final = rho;
ResetScrnLineAtTop();
if(printer > 0)
PRINT
"new value=%lf; ON NUMERIC KEYPAD:7 halves rhostep,9 doubles it\n"
,*pIncrement);
return(YES);
}
if(kk == '-') {
start(); /* sets dot = 0 and lyap exponents are
restarted */
old_rho = rho;
*pIncrement -= rho_step;
if(pIncrement == &rho && rho_final == old_rho)
rho_final = rho;
ResetScrnLineAtTop();
if(printer > 0)
PRINT
"new value=%lf; ON NUMERIC KEYPAD:7 halves rhostep,9 doubles it\n"
,*pIncrement);
return(YES);
}
if(kk == '*') {
ResetScrnLineAtTop();
OptionsHelp(); /* in yopmenus.c */
return(YES);
}
if(kk == '?') {
ResetScrnLineAtTop();
getText("yintrpt.doc", "keys");
erase_line();
PRINT
"==== Hit r to refresh the screen =========== Hit * plus key for more help===="
);
return(YES);
}
if((kk >= '0') &&(kk <= '3')) {
printer = kk - '0';
return(YES);
}
if((kk >= '4') &&(kk <= '6')) {
/* Setting kk >= '3' causes lyap exponents and
ordinary differential equation error data to
be printed out as it is computed Setting '4'
causes a point data to be printed on first
call of iterate_map() which then resets
printer to 2. Setting kk = '5' causes
position vector to be printed EVERY TIME a
point is ITERATED which can be more frequent
than plotting. Used in iterate_map. */
if(checkPrinter() == YES) {
/* in YPLOT.C; means printer is on line and
ready to print */
printer = kk - '0';
print_text(StPrint);
/* text goes to printer before stream of data
if "printer" >= 1 */
printer = kk - '0';
}
return(YES);
}
if(kk == 'a') {
cycle = 0;
dot = dots;
return(YES);
}
if(kk == 'b') { /* toggle for drawing a box using scale, */
draw_box();
return(YES);
}
if(kk == 'B') { /* toggle for drawing a box using scale, */
ss = ScrnSec;
X_lower = X_low = x_new_low = X_Lo[ss];
Y_lower = Y_low = y_new_low = Y_Lo[ss];
X_upper = X_upp = x_new_upp = X_Up[ss];
Y_upper = Y_upp = y_new_upp = Y_Up[ss];
PrintBoxCoordinates();
/* if printer > 1; prints coordinates of
screen */
return(YES);
}
if(kk == 'c') { /* to clear screen and p[][], hit C; to clear
just the active frame, hit c, which is the
same as C if ScrnSec = 0 */
if(ScrnSec == 0) {
/* this turns window overlap prevention off */
for(i = 0; i <= 4; i++)
windowflag[i] = OFF;
}
clrWindow();
if(printer == 3)
bottomPrint();
SetCross(SMALLCROSS);
return(YES);
}
if(kk == 'C') { /* to clear screen and p[][], hit C; to clear
just the active frame, hit c, which is the
same as C if ScrnSec = 0 */
if(ScrnSec == 0) {
/* this turns window overlap prevention off */
for(i = 0; i <= 4; i++)
windowflag[i] = OFF;
}
stoplines(); /* for stopping drawing connected lines */
SignIsOn = 0; /* sign about jump size */
IsCross0Set = NO;/* screen cross at y0 is not set */
IsCross1Set = NO;/* screen cross at y1 is not set */
scr_clr(); /* in desmets pcio.a */
clearp();
return(YES);
}
if(kk == 'e') {
if(step > -9999)
ODEcheck += 2;
/* when dif eq is next called, it will call
error_check,(in YTOOLS.C) and it will report
error and then will reduce ODEcheck since it
is greater than 1; */
return(YES);
}
if(kk == 'E') {
if(step != -9999.) {
if(printer > 0 && ODEcheck == OFF) {
PRINT
"Differential equation errors will be printed every interate if interrupt \n");
PRINT
"key '3' is set; otherwise they will be computed but not printed. \n");
PRINT
"Hit 'e' to get update on errors computed so far.\n");
}
ODEcheck = 1 - ODEcheck;
erase_line();
PRINT
"CALCULATION of errors is now turned \n");
toggle(ODEcheck);/* prints " ON\n" or " OFF\n" */
}
return(YES);
}
if(kk == 'i') { /* re-initializes y[] to = y1[] */
interrupti(); /* in YCOMY.C; re-initializes y[] to = y1[] */
return(YES);
}
if(kk == 'I') { /* turns on feature whereby each movement of
the cursor is followed by "images" iterates
of the map, plotting each dot along the way
*/
images++;
plotImages();
scr_rowcol(1, 0);
if(printer > 0) {
erase_line();
PRINT
"Number of images of small cross now = %d\n", images);
erase_line();
PRINT
"This image feature is turned off by hitting 'i' or with command \"IMAGES\"\n"
);
}
stoplines(); /* for stopping drawing connected lines */
return(YES);
}
if(kk == 'j') {
jay();
return(YES);
}
if(kk == 'k') { /* When cross0flag = 1, program makes a
temporary cross as each dot is plotted,
erasing it when it is time to plot the next
*/
turnoff(BIGCROSS);
cross0flag = 1 - cross0flag;
return(YES);
}
if(kk == 'K') { /* for making big cross permanent on both crt
and core */
/* reverses a big cross permanent on both crt and core; temporarily we
turn off the other crosses */
plotSomething(0);
/* sets plotX,plotY and plots a point but does
not iterate */
if((temp = IsCross0Set) == YES)
turnoff(BIGCROSS);
if((temp1 = IsCross1Set) == YES)
turnoff(SMALLCROSS);
ResetScrnLineAtTop();
#ifdef X11
CRTcrossON(plotX, plotY, CORECOLS / 50, (8 * COREROWS) / 36,
CORE);
#else
if(printer > 1)
PRINT
"Cross drawn at y[] on core; \r");
drawcross(plotX, plotY, CORECOLS / 50,(8 * COREROWS) / 36, CORE);
#endif
/* permanent cross in core */
CRTcrossON(plotX, plotY,(3 * SCRNCROSSWIDTH) / 4,
(3 * SCRNCROSSHEIGHT) / 4, color);
/* permanent midsize cross in CRT */
if(temp1 == YES)
SetCross(BIGCROSS);
if(temp == YES)
SetCross(SMALLCROSS);
if(cycle == 0) {
return(RET);
/* this allows us to hold down the 'K' key and
get a series of crosses; I don't know every
dot will then get a cross; that would depend
on how fast the keyboard sends signals to
the cpu. */
}
return(YES);
}
if(kk == 'l') {
ResetScrnLineAtTop();
if(num_lyap != -9999 && num_lyap != 0)
print_lyap(StOutPut);
else {
PRINT
"Lyapunov exponents are not being calculated; see L: in parameter menu\r");
}
return(YES);
}
if(kk == 'L') {
abcd(); /* in YCOMU.C */
return(YES);
}
if(kk == 'm') { /* transfer from one vec to another */
MoveVec(); /* after this call, ystore_in is the address of
the changed vector */
SetCross(SMALLCROSS);
if(ystore_in == y && cycle > 0)
SetCross(BIGCROSS);
if(ystore_in == y) {
stoplines(); /* for stopping drawing connected lines */
plotSomething(0);/* sets plotX,plotY and plots */
start();
/* sets dot = 0 and lyap exponents are restarted */
}
return(YES);
}
if(kk == 'O') {
stoplines(); /* for stopping drawing connected lines */
scr_rowcol(1, 0);
if(printer >= 2) {
erase_line();
PRINT
"Hit 'I' to increase the number of images of the circle, 'i' to set it to 0\n"
);
PRINT
"Type #RA to chang radius of circle; use arrow keys to move the center.\n");
PRINT
"HIT SPACE BAR ONCE ONLY when you now want to terminate circle routine \n");
PRINT
"####################### Hit r to refresh the screen. ########################"
);
}
oldTaskFlag = taskFlag;
taskFlag = 100;
overflow = NO;
caseT();
if(overflow == YES)
/* maybe == Yes from leaving box in caseT */
cycle = 2;
if(printer > 0)
PRINT
"####################### Hit r to refresh the screen. ########################"
);
taskFlag = oldTaskFlag;
kk = 'O'; /* note kk is static */
images = 0;
if(printer > 0)
PRINT
"The number of \"IMAGES\" is set to 0 \n");
return(YES);
}
if(kk == 'P') { /* print copy of picture */
pprint(onprint);
/* kk = keycheck(); this lets you hit escape now */
beep();
return(YES);
} /* note that keycheck()=='p' does not Interrupt
printing p[][] */
if(kk == 'q') { /* print parameters etc on crt */
ResetScrnLineAtTop();
time1 = timeofday();
if(dot > 1 && dot > dotAtTime0
&& time1 >= time0
&& time0 != 0
&& time1 != 0 && printer > 0) {
doubleDot = (dot - dotAtTime0) /(time1 - time0);
if(printer > 0)
PRINT
"dots per second = %lf, seconds per dot = %lf \n"
,doubleDot, 1 / doubleDot);
}
print_text(StOutPut);
if(IsCross1Set == YES && printer > 0) {
ss = ScrnSec;
erase_line();
PRINT
"small cross at y1: X=%e Y=%e.Arrows change X by %lf\n",
y[eqn0 + ssX_coord[ss]], y[eqn0 + ssY_coord[ss]]
,screen_fraction *(X_upper - X_lower));
}
for(i = 0; i < 10; i++)
if(message[i] != defaultMessage)
PRINT message[i]);
return(YES);
}
if(kk == 'Q') {
#ifdef X11
printf("Color is not implemented yet\n");
#else
setRGBColor(); /* will be asked for 3 integers */
#endif
return(YES);
}
if(kk == 'r') { /* reboot screen to erase text */
stoplines(); /* for stopping drawing connected lines */
boot = 1;
boot_crt();
if(cycle > 0) {
SetCross(SMALLCROSS);
SetCross(BIGCROSS);
}
return(YES);
}
if(kk == 's') { /* changes scale to new values, resets
temporary values to zero, and moves y_init
to the center of the new screen, and resets
"diameters" */
ResetScrnLineAtTop();
if(printer > 2)
PRINT
"currently plotting in screen section number %d \n"
,ScrnSec);
erase_line();
if(printer > 0) {
PRINT
"Hit new sec. num.: F1=up.left; F2=up.right; F3=low.left; F4=low.rt.;F10=whole"
);
PRINT "\r");
}
#ifdef X11
digit = awaitkey(0);
#else
while((digit = keycheck()) == 0) {
}; /* keep trying until a character is entered */
#endif
/* note that F1 = -59,...,F4= -62, so F1>F4 */
if(digit == F1)
digit = '1';
if(digit == F2)
digit = '2';
if(digit == F3)
digit = '3';
if(digit == F4)
digit = '4';
if(digit == F10)
digit = '0';
/* so digit now has a value between 1 and 4 or = 10 */
if((digit >= '0' && digit <= '4'))
{
openWindow(digit-'0');
}
else {
erase_line();
PRINT "Section %d is not acceptible \r", digit);
}
return(YES);
}
if(kk == 'u') { /* reverses process s)cale */
unWindow();
return(YES);
}
if(kk == 't') { /* draws box with 4 to 9 tic marks on each side
*/
if(printer > 2) {
scr_rowcol(5, 0);
erase_line();
PRINT
"Use Interrupt 'T' for small tic marks that are 5 times finer\n");
}
oldTicFlag = ticFlag;
ticFlag = ON;
draw_box(); /* calls PrintBoxCoordinates */
ticFlag = oldTicFlag;
return(YES);
}
if(kk == 'T') { /* draws extra fine set of tic marks with 1/5
resolution */
set_box(); /* should not be necessary */
if(set_box() != 0)
ticMarks(2);
/* draws an extra set of fine tic marks */
else
scr_rowcol(3, 0), PRINT "BOX IS DEFECTIVE.\n");
return(YES);
}
if(kk == 'v') { /* 'v' inverts differential equations and
henon: map x -> rho - x*x + C1*y
inverse -y/C1 -> rho/(C1**2) -(-y/C1)**2
+(-x/C1)/C1 */
invert(); /* in YCOMNDS1.C */
return(YES);
}
if(kk == 'w') { /* print position of small cross on screen */
if(crossStatus == OFF) {
crossStatus = ON;
CrossPosition();
}
/* if crossStatus is ON, we print position of small cross */
else {
scr_rowcol(2, 28);
crossStatus = OFF;
if(printer > 0)
PRINT
" ");
scr_rowcol(0, 0);
}
return(YES);
}
if(kk == 'W') { /* print position of small cross on screen */
scr_rowcol(3, 0);
whenAndWhere();/* for interrupt W and command W */
scr_rowcol(0, 0);
return(YES);
}
if(kk == 'x') { /* change X_lower to y[eqn0+X_coord] */
x_new_low = y[eqn0 + ssX_coord[ScrnSec]];
return(YES);
}
if(kk == 'X') { /* change X_upper to y[eqn0+X_coord] */
x_new_upp = y[eqn0 + ssX_coord[ScrnSec]];
return(YES);
}
if(kk == 'y') { /* change Y_lower to y[eqn0+Y_coord] */
y_new_low = y[eqn0 + ssY_coord[ScrnSec]];
return(YES);
}
if(kk == 'Y') { /* change Y_upper to y[eqn0+Y_coord] */
y_new_upp = y[eqn0 + ssY_coord[ScrnSec]];
return(YES);
}
if(kk == 'z') {
/* int printerStatus(num) initializes the printer and returns status
byte; meaning of bit: 7 printer busy 6 Acknowledge 5 out of
paper 4 selected 3 I/O error 2,1 not used 0 time
out */
PRINT "\n printer status code 1: %d\n", printerStatus(1));
PRINT "\n printer status code 2: %d\n", printerStatus(2));
PRINT
"keyboard status %d; \n", shift);
return(YES);
}
#ifdef MS
if(kk == 'Z') {
scr_rowcol(5, 5);
if(++palette > 3)
palette = 0;
_selectpalette(palette);
PRINT " scrncols = %d ,scrnrows = %d palette = %d \n"
,scrncols, scrnrows, palette);
return(YES);
}
#endif
if(kk == F1 || kk == F2 || kk == F3 || kk == F4 || kk == F10)
{
if(kk == F1)
ss = 1;
else if(kk == F2)
ss = 2;
else if(kk == F3)
ss = 3;
else if(kk == F4)
ss = 4;
else if(kk == F10)
ss = 0;
switchToWindow(ss);
return(YES);
}
#ifdef MS
if(kk == F5) { /* reinitiallizes y = y1 and then does F7() */
interrupti(); /* in YCOMY.C; re-initializes y[] to = y1[] */
f7();
return(YES);
}
if(kk == F6) {
interrupti(); /* re-initializes y[] to = y1[] */
f8();
return(YES);
}
if(kk == F7) { /* decreases color number by 1 */
f7();
return(YES);
}
if(kk == F8) { /* increases color number by 1 */
f8();
return(YES);
}
if(kk == F9) {
f9();
return(YES);
}
#endif
return(NO); /* no interrupt for this kk */
}
#endif /* ifndef MAINFRAME */
start() { /* used in printing the vector lyapsum */
erase_line();
dot = 0; /* dot = 0 restarts lyap exponents */
time0 = timeofday();
dotAtTime0 = dot;
}
#ifdef MS
f7() /* decreases number of active color by 1 */
{
#ifndef MAINFRAME
turnoff(BIGCROSS);
turnoff(SMALLCROSS);
#endif /* if not def MAINFRAME */
if(color > 0)
color--;
#ifndef MAINFRAME
_setcolor(color);
scr_rowcol(2, 5);
#endif /* if not def MAINFRAME */
if(SCREEN && printer >= 2)
PRINT "new color = %d \n", color);
if (SCREEN && printer == 1)
PRINT " %d \n",color);
#ifndef MAINFRAME
SetCross(SMALLCROSS);
turnoff(SMALLCROSS);
SetCross(SMALLCROSS);
#endif /* if not def MAINFRAME */
}
f8() /* increases number of active color by 1 */
{
#ifndef MAINFRAME
turnoff(BIGCROSS);
turnoff(SMALLCROSS);
#endif /* if not def MAINFRAME */
color++;
#ifndef MAINFRAME
_setcolor(color);
scr_rowcol(2, 5);
#endif /* if not def MAINFRAME */
if(SCREEN && printer >= 1)
PRINT "new color = %d \n", color);
#ifndef MAINFRAME
SetCross(SMALLCROSS);
turnoff(SMALLCROSS);
SetCross(SMALLCROSS);
#endif /* if not def MAINFRAME */
}
f9() {
int colorNum;
double Entervalue();
colorNum = color;
colorNum = Entervalue((double)colorNum, CHECKSET);
if(colorNum >= 0) {
#ifndef MAINFRAME
turnoff(BIGCROSS);
turnoff(SMALLCROSS);
scr_rowcol(2, 5);
#endif /* if not def MAINFRAME */
color = colorNum;
if(SCREEN && printer >= 2)
PRINT "new color = %d \n", color);
#ifndef MAINFRAME
_setcolor(color);
SetCross(SMALLCROSS);
turnoff(SMALLCROSS);
SetCross(SMALLCROSS);
#endif /* if not def MAINFRAME */
}
}
#endif /* MS */
openWindow(num)
int num;
{
if (num<0 || num >4)
return;
/* before switching sections, turn off crosses */
stoplines(); /* for stopping drawing connected lines */
UvsSflag = 0; /* this says s was called more recently than u */
turnoff(BIGCROSS);
turnoff(SMALLCROSS);
OldScrSec = ScrnSec;
ScrnSec = num;
if(ScrnSec != 0) {
windowflag[0] = ON;
windowflag[ScrnSec] = ON;
}
erase_line();
X_coord = ssX_coord[ScrnSec] = ssX_coord[OldScrSec];
Xplot[ScrnSec] = &y[X_coord];
Y_coord = ssY_coord[ScrnSec] = ssY_coord[OldScrSec];
Yplot[ScrnSec] = &y[Y_coord];
if(printer > 0)
PRINT
"New section %d, coordinates x=%d, y=%d \r", ScrnSec, X_coord, Y_coord);
OldDiameters = diameters[ScrnSec];
resetDiameters();
/* in YPLOT.C; diameters must be reset before
scale is changed */
/* Recall: SetAndSave (new,current,old) saves *current in *old
and if new is set, it sets *current = *new; it then sets
*new = *current double *new,*current,*old */
SetAndSave(&x_new_low, &X_lower, &x_old_low);
SetAndSave(&y_new_low, &Y_lower, &y_old_low);
SetAndSave(&x_new_upp, &X_upper, &x_old_upp);
SetAndSave(&y_new_upp, &Y_upper, &y_old_upp);
ScreenConstants();
/* defines ax,bx where x = 0,00,1,2 */
clrWindow();
draw_box();
/* We used to center cross in window: y[eqn0+ssX_coord[ss]] =
(X_lower + X_upper)/2; y[eqn0+ssY_coord[ss]] = (Y_lower +
Y_upper)/2;
*/
SetCross(SMALLCROSS);
}
switchToWindow(ss)
int ss;
{
if (ss < 0 || ss > 4)
{
PRINT
"No SUCH WINDOW EXISTS \n");
return;
}
stoplines(); /* for stopping drawing connected lines */
if(allSSFlag == YES)
{/* now plot in only one frame */
allSSFlag = NO;
if(X_coord >= 0 && Y_coord >= 0 && X_coord != Y_coord)
taskFlag = PLOTXY;
else
PRINT
"To resume plotting in just that window, return to menu and CONTinue process\n"
);
}/* if allSSFlag */
/* If either cross is on then turn it off */
turnoff(BIGCROSS);
turnoff(SMALLCROSS);
if(xScrPix[ss] == -9999)
PRINT
"Not acceptable: THIS WINDOW IS NOT OPEN; first set scale using 's' \n");
else
{
ScrnSec = ss;
X_lower = X_Lo[ss];
X_upper = X_Up[ss];
Y_upper = Y_Up[ss];
Y_lower = Y_Lo[ss];
ScreenConstants();
if(ss != 0)
{
windowflag[0] = ON;
if(windowflag[ss] == OFF)
{
clrWindow();
draw_box();
}
windowflag[ss] = ON;
}/* end if */
SetCross(SMALLCROSS);
ResetScrnLineAtTop();
if(printer > 2)
PRINT
"currently plotting in screen section number %d \n"
,ScrnSec);
}/* end else */
}
unWindow()/* called by interrpt 'u': undoes 's' more or less */
{
stoplines(); /* for stopping drawing connected lines */
if(UvsSflag == 1) {
/* this means 'u' is being used as a toggle */
/* the following 4 resets the box to be the old box */
SwitchD(&x_old_low, &x_new_low);
SwitchD(&y_old_low, &y_new_low);
SwitchD(&x_old_upp, &x_new_upp);
SwitchD(&y_old_upp, &y_new_upp);
}
UvsSflag = 1; /* this says 'u' was called more recently than
's'; */
turnoff(BIGCROSS);
turnoff(SMALLCROSS);
if(OldDiameters == -9999.) {
erase_line();
PRINT
"Cannot unscale ('u') because no old scale is set\n");
return(RET);
}
SwitchI(&ScrnSec, &OldScrSec);
SwitchD(&diameters[ScrnSec], &OldDiameters);
X_coord = ssX_coord[ScrnSec] = ssX_coord[OldScrSec];
Xplot[ScrnSec] = &y[X_coord];
Y_coord = ssY_coord[ScrnSec] = ssY_coord[OldScrSec];
Yplot[ScrnSec] = &y[Y_coord];
/* Recall: SetAndSave(new,current,old) saves *current in *old and if
new is set, it sets *current = *new; it then sets *new = *current
double *new,*current,*old */
/* without the following 4 lines, the box doesn't change */
SwitchD(&x_old_low, &x_new_low);
SwitchD(&y_old_low, &y_new_low);
SwitchD(&x_old_upp, &x_new_upp);
SwitchD(&y_old_upp, &y_new_upp);
SetAndSave(&x_new_low, &X_lower, &x_old_low);
/* same as in 's' */
SetAndSave(&y_new_low, &Y_lower, &y_old_low);
SetAndSave(&x_new_upp, &X_upper, &x_old_upp);
SetAndSave(&y_new_upp, &Y_upper, &y_old_upp);
ScreenConstants();/* defines ax,bx where x = 0,00,1,2 */
/* the following 4 resets the box to be the old box */
SwitchD(&x_old_low, &x_new_low);
SwitchD(&y_old_low, &y_new_low);
SwitchD(&x_old_upp, &x_new_upp);
SwitchD(&y_old_upp, &y_new_upp);
if(ScrnSec == 0)
boot_crt();/* this clears p and the screen */
SetCross(SMALLCROSS);
}